<template>
    <popup title="提示">
        <view class="content">{{ content }}</view>
        <button
            class="short-btn active"
            :open-type="type"
            @getphonenumber="getPhoneNumber"
            @click="getUserInfo"
        >
            授权
        </button>
    </popup>
</template>
<script lang="ts" setup>
import { defineEmits } from 'vue'
import popup from '@/components/popup/popup.vue'
// import global from '@/utils/global'
// import user from '@/utils/user'
defineProps(['type', 'content'])
const emits = defineEmits(['complete'])
const getPhoneNumber = (res: {
    detail: {
        encryptedData: string
        iv: string
    }
}) => {
    if (res.detail.encryptedData) {
        // const data = {
        //     appId: global.appId,
        //     encryptedData: res.detail.encryptedData,
        //     sessionKey: user.session_key,
        //     iv: res.detail.iv
        // }
        // encryptedPhoneData(data).then((res) => {
        //     this.$toast('授权成功')
        //     this.$emit('complete', res.phoneNumber)
        // })
    }
}
const getUserInfo = () => {
    uni.getUserProfile({
        desc: '用于团队协作时的个性化展示',
        success (res) {
            emits('complete', {
                avatarUrl: res.userInfo.avatarUrl,
                nickName: res.userInfo.nickName
            })
        }
    })
}
</script>
<style lang="scss">
.content {
    margin: 20rpx 0 70rpx;
    font-size: 28rpx;
    color: $uni-text-color-grey;
}
</style>
